let lang = localStorage.getItem("language");
$(document).ready(function() {
    /*默认语言*/
    var defaultLang = lang || "cn";
    $("[i18n]").i18n({
        defaultLang: defaultLang,
        filePath: "/assets/vitae/i18n/", //路径配置
        filePrefix: "i18n_",
        fileSuffix: "",
        forever: true,
        callback: function() {
            console.log("i18n is ready.");
        },
    });
    /*中英文切换按钮*/
    $("#translate-button").click(function(e) {
        let lang = localStorage.getItem("language");
        if (lang) {
            $(e.target).val(lang);
        }
        var a = $(e.target).val() == "cn" ? "en" : "cn";
        $(e.target).val(a);
        // $("#translate-button").text(b);
        console.log($(e.target).val());
        localStorage.setItem("language", a);
        $("[i18n]").i18n({
            defaultLang: a,
            filePath: "/assets/vitae/i18n/",
        });

    });

})